# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=arping-th
_pkgname=arping
pkgver=2.25
pkgrel=2
pkgdesc='ARP Ping from Thomas Habets (aka Debian arping).'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-networking')
url='https://github.com/ThomasHabets/arping'
license=('GPL-2.0-or-later')
depends=('libnet' 'libcap' 'libpcap')
source=("https://github.com/ThomasHabets/arping/archive/refs/tags/$_pkgname-$pkgver.tar.gz")
sha512sums=('7cfc1ed73bd7621911f9b1b0ad23680c7dde6f8674a0223e6341dc6e40c7d49bb293bc519e9e9de8abaa9209ad7fedad902901235f87b8d21395f3396739b922')

prepare() {
  cd "$_pkgname-$_pkgname-$pkgver"

  autoreconf -i
  # package binary as arping-th to avoid conflict with /usr/bin/arping from iputils (base) package
  # dracut depends on iputils arping and both arping are not intercompatible so packaing TH arping under
  #   /usr/local/bin is not an option
  ./configure --prefix=/usr --program-suffix="-th" --sbindir=/usr/bin
}

build() {
  cd "$_pkgname-$_pkgname-$pkgver"

  make
}

package() {
  cd "$_pkgname-$_pkgname-$pkgver"

  make DESTDIR="$pkgdir" install

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md INSTALL

  install -Dm 644 "doc/$_pkgname.8" "$pkgdir/usr/share/man/man8/$pkgname.8"
}

